package fresher.servletcontroller;

import fresher.model.ExampleModel;
import fresher.utility.TemplateManager;
import hapax.Template;
import hapax.TemplateDataDictionary;
import hapax.TemplateDictionary;
import hapax.TemplateException;
import hapax.TemplateLoader;
import hapax.TemplateResourceLoader;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TotalRenderServletController extends HttpServlet {
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        
        TemplateDataDictionary dictionary = TemplateDictionary.create();
        
        //Process business logic
       //Render output 
        String content = "";
        try {
            content = TemplateManager.getInstance().getTemplate("/view/total.xtm").renderToString(dictionary);
        } catch (TemplateException ex) {
            ErrorServletController.showError(request, response, ex.getMessage());
        }

        //Réponse
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        response.getWriter().println(content);
    }
}